# Contributor: alpine-mips-patches <info@mobile-stream.com>
# Maintainer: alpine-mips-patches <info@mobile-stream.com>
pkgname=ocaml-camlp5
_pkgname=camlp5
pkgver=7.07
_pkgver="rel707"
pkgrel=0
pkgdesc="Preprocessor-pretty-printer of OCaml"
url="https://camlp5.github.io"
arch="aarch64 ppc64le x86_64"  # reflect ocaml aport platforms
license="BSD"
depends="ocaml-runtime"
makedepends="ocaml ocaml-compiler-libs"
options="!check"
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$_pkgver.tar.gz::https://github.com/camlp5/$_pkgname/archive/$_pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$_pkgver"

build() {
	cd "$builddir"
	./configure \
		--prefix /usr \
		--bindir /usr/bin \
		--libdir /usr/lib/ocaml \
		--mandir /usr/share/man
	make
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install
}

dev() {
	# mkcamlp5* call ocamlc
	depends="$pkgname=$pkgver-r$pkgrel ocaml ocaml-compiler-libs"
	pkgdesc="$pkgdesc (development files)"

	local _bindir="usr/bin"
	mkdir -p "$subpkgdir/$_bindir"
	mv "$pkgdir/$_bindir/"mkcamlp5* "$subpkgdir/$_bindir"

	local _camlp5dir="usr/lib/ocaml/camlp5"
	mkdir -p "$subpkgdir/$_camlp5dir"
	for p in '*.a' '*.cmx' '*.cmxa' '*.mli' '*.o'; do
		mv "$pkgdir/$_camlp5dir/"$p "$subpkgdir/$_camlp5dir"
	done
}

sha512sums="e396c109c67383ba56f3ada43f5b5ece8b2339528553802386a1d9637a151a14d7dfc48c0a4219b24ca53fad7acfddfd4dc2c1fe109ced8b71f16202b94b8cf6  ocaml-camlp5-rel707.tar.gz"
